#pragma once 
#pragma once 
#include <iostream>
#include <string>
using namespace std;
#include <unistd.h>
#include <functional>
#include <vector>
#include <cstdlib>
#include <time.h>


//任务管理
class TaskManager
{
    using func = function<void()>;
public:
    TaskManager(){
        srand(time(nullptr));
    }
    void Insert(func f){
        _tasks.emplace_back(f);
    }
    void Execute(int cmd){
        if (_tasks.empty()) {
            cout << "任务队列为空" << endl;
            return;
        }
        _tasks[cmd]();
    }
    int Select(){
        return rand() % _tasks.size();
    }
private:
    vector<func> _tasks; //任务队列
};

TaskManager tm;